/**
 * Created by HP on 2016/10/27.
 */

var dayshowText = {
    '2016.10.10': "体能训练",
    '2016.10.20': "心情管理",
    '2016.10.30': "运动管理",
    '2016.11.01': "11月运动管理",
    '2016.11.10': "11月心情管理",
    '2016.11.20': "11月体能训练",
    '2016.11.30': "11月监测计划",
    '2016.12.01': "12月监测计划",
    '2017.1.10': "2017年计划"
};

//以上是模拟ajax接口调用--初始化日历,可以删除(还有一部分在my-sm.js开头,也可删除)



function showDateText(year,month,date) {
    var dateformat = year+"."+month+"."+date;
    var dateText = dayshowText[dateformat];
    if(dateText == undefined){
        $(".databg-showinfo-text").text("没有监测计划");
        $(".textarea").val("没有监测计划");
    }else{
        $(".databg-showinfo-text").text(dateText);
        $(".textarea").val(dateText);
    }
}
var today = new Array('星期日','星期一','星期二','星期三','星期四','星期五','星期六');

var chart;
var chart2;
$(document).ready(function () {
    //监测计划显示日期

    var dataDay='';
    var mydate = new Date();
    var year = mydate.getFullYear();
    var month = parseInt(mydate.getMonth())+1;
    var date = mydate.getDate();
    var week = today[mydate.getDay()];
    if(parseInt(date) < 10){
        dataDay = "0"+date;
    }
    $(".databg-showdata").text(date);
    var yearMonth = year+"年"+month+"月";
    $(".databg-showinfo-yearmonth").text(yearMonth);
    $(".databg-showinfo-week").text(week);
    showDateText(year,month,date);



    //areaspline 填充图示例
    chart = new Highcharts.Chart({
        chart: {
            renderTo: 'chart1',          //放置图表的容器
            plotBackgroundColor: null,
            plotBorderWidth: null,
            defaultSeriesType: 'areaspline'   //图表类型line, spline, area, areaspline, column, bar, pie , scatter
        },
        title: {
            text: ''
        },
        xAxis: {//X轴数据
            categories: ['16', '17', '18', '19', '20', '21', '22'],
            labels: {
                rotation: 0, //字体倾斜
                align: 'center',
                style: { font: 'normal 12px text_font'}
            }
        },
        yAxis: {//Y轴显示文字
            max:50, // 定义Y轴 最大值
            min:0, // 定义最小值
            minPadding: 0.2,
            maxPadding: 0.2,
            tickInterval:10, // 刻度值
            title: {
                text: ''
            }
        },
        tooltip: {
            enabled: true,
            formatter: function() {
                return '<b>' + this.x + '</b><br/>' + this.series.name + ': ' + Highcharts.numberFormat(this.y, 1) + "";
            }
        },
        plotOptions: {
            column: {
                dataLabels: {
                    enabled: true
                },
                enableMouseTracking: true//是否显示title
            }
        },
        series: [{
            name: '最近7天心情指数',
            data: [7.0, 16.9, 29.5, 24.5, 38.4, 21.5, 29.2]
        }, {
            name: '上周心情指数',
            data: [4.0, 2.9, 15.5, 34.5, 28.4, 11.5, 35.2]
        },]
    });
    chart2 = new Highcharts.Chart({
        chart: {
            renderTo: 'chart2',          //放置图表的容器
            plotBackgroundColor: null,
            plotBorderWidth: null,
            defaultSeriesType: 'areaspline'   //图表类型line, spline, area, areaspline, column, bar, pie , scatter
        },
        title: {
            text: ''
        },
        xAxis: {//X轴数据
            categories: ['16', '17', '18', '19', '20', '21', '22'],
            labels: {
                rotation: 0, //字体倾斜
                align: 'center',
                style: { font: 'normal 12px text_font' }
            }
        },
        yAxis: {//Y轴显示文字
            max:50, // 定义Y轴 最大值
            min:0, // 定义最小值
            minPadding: 0.2,
            maxPadding: 0.2,
            tickInterval:10, // 刻度值
            title: {
                text: ''
            }
        },
        tooltip: {
            enabled: true,
            formatter: function() {
                return '<b>' + this.x + '</b><br/>' + this.series.name + ': ' + Highcharts.numberFormat(this.y, 1) + "";
            }
        },
        plotOptions: {
            column: {
                dataLabels: {
                    enabled: true
                },
                enableMouseTracking: true//是否显示title
            }
        },
        series: [{
            name: '最近7天心情指数',
            data: [7.0, 6.9, 9.5, 14.5, 18.4, 21.5, 25.2]
        }, {
            name: '上周心情指数',
            data: [4.0, 2.9, 5.5, 24.5, 18.4, 11.5, 35.2]
        },]
    });
    var mySwiper = new Swiper('.swiper-container',{
        pagination : '.swiper-pagination',
    })
})


$(".item-toggle1").click(function () {
    $("#hiddenpicker").val("pickerstr1");
    if($(".item-toggle1 > .item-sel").is(":hidden")){
        $(".item-toggle1 >.item-sel").show();
        $(".item-toggle1 > .item-unsel").hide();
    }else{
        $(".item-toggle1 > .item-unsel").show();
        $(".item-toggle1 > .item-sel").hide();
    }
})
$(".item-toggle2").click(function () {
    $("#hiddenpicker").val("pickerstr2");
    if($(".item-toggle2 > .item-sel").is(":hidden")){
        $(".item-toggle2 >.item-sel").show();
        $(".item-toggle2 > .item-unsel").hide();
    }else{
        $(".item-toggle2 > .item-unsel").show();
        $(".item-toggle2 > .item-sel").hide();
    }
})

$(".changeicon").click(function () {
    if($(this).hasClass('shuffle')){
        $(this).removeClass('shuffle').addClass('repeat')
    }else{
        $(this).removeClass('repeat').addClass('shuffle')
    }
})

$(".sub-succ").click(function () {
    $.alert("监测计划添加成功(通过ajax)");
})


$(".right-more").click(function () {
    $(".more-setting").show();
})

$(".right-more").blur(function () {
    $(".more-setting").hide();
})

$(".my-tab-item").click(function () {
    $(".my-tab-item > .icon-pic").removeClass("my-icon-me-sel my-icon-discover-sel my-icon-home-sel my-icon-mess-sel");
    $(".my-tab-item").removeClass("font-color-active");
    $(this).addClass("font-color-active");
    var child = $(this).find('div.icon-pic');

    if (child.hasClass("my-icon-home")) {
        child.addClass("my-icon-home-sel");
    }
    if (child.hasClass("my-icon-mess")) {
        child.addClass("my-icon-mess-sel");
    }
    if (child.hasClass("my-icon-discover")) {
        child.addClass("my-icon-discover-sel");
    }
    if (child.hasClass("my-icon-me")) {
        child.addClass("my-icon-me-sel");
    }
})
